#include "mainwindow.h"
#include "ui_mainwindow.h"

#include<QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{

    ui->setupUi(this);
    ui->lineEdit_IP->setText("192.168.1.2");
    ui->lineEdit_port->setText("4600");
    server=new MyServer();
    connect(server,SIGNAL(dataReady(char *)),this,SLOT(onShowMsg(char*)));

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::onSetCondition()
{
    ui->label_condition->setText("gt client!");
}






void MainWindow::on_pushButton_connect_clicked()
{
    //设置服务器端监听

    int port=ui->lineEdit_port->text().toInt();

    server->listen(QHostAddress::Any,port);
    ui->label_condition->setText("start liston!");
    qDebug()<<"start listen"<<endl;

}

void MainWindow::onShowMsg(char *data)
{
    ui->textBrowser_record->append(data);
    ui->label_condition->setText("gt c!");
    qDebug()<<data<<endl;
}

